<?php
class Controller
{
    static $actionTemplate;
    static $database;

    protected $_at;
    
    /**
     *
     * @return Controller
     */
    static function getActionTemplate()
    {
//        require_once('includes/Init.php');
        if (is_null(self::$actionTemplate)){
//            echo "create Action Template";
            self::$actionTemplate = new Smarty();
            self::$actionTemplate->setTemplateDir(getDocumentRoot() . 'templates');
            self::$actionTemplate->setCompileDir(getDocumentRoot() . 'templates_c');
            self::$actionTemplate->setCacheDir(getDocumentRoot() . 'smarty/cache');
            self::$actionTemplate->setConfigDir(getDocumentRoot() . 'smarty/configs');
        }
        return self::$actionTemplate;
    }

    static function getDatabase($host) {
        if (is_null(self::$database) ){
            self::$database = new MyDb($host);
        }
//        print_r(self::$database->text());
        return self::$database;
    }

//    /**
//     *
//     * @return Smarty
//     */
//    public function at()
//    {
//
//        if (!$this->_at) {
//            $this->_at = new Smarty();
//            $this->_at->setTemplateDir(getDocumentRoot() . 'templates');
//            $this->_at->setCompileDir(getDocumentRoot() . 'templates_c');
//            $this->_at->setCacheDir(getDocumentRoot() . 'smarty/cache');
//            $this->_at->setConfigDir(getDocumentRoot() . 'smarty/configs');
//        }
//        return $this->_at;
//    }
}
